home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Utilities / MandelNet / myabout.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-14  |  3.4 KB  |  160 lines  |  [TEXT/KAHL]

  1. #define    DURATION        1
  2.  
  3.  
  4.  
  5. DoAboutBox(doWait)
  6. int    doWait;
  7. {
  8. Rect            creditRect, lineRect;
  9. GrafPtr            oldPort;
  10. WindowPtr        creditWPtr;
  11. EventRecord        theEvent;
  12. long            iticks;
  13. char            *line1 = "MandelNet 1.0";
  14. char            *line2 = "Written by Roy Wood";
  15.  
  16. char            *line3 = "A parallel-processing Mandelbrot generator";
  17. char            *line4 = "for use on AppleTalk networks";
  18.  
  19. char            *line5 = "©1991 Silicon Angst Software";
  20. char            *line6 = "122 Britannia Avenue";
  21. char            *line7 = "London, Ontario, Canada N6H 2J5";
  22. char            *line8 = "(519) 438-3177";
  23. int                count,i;
  24. int                x[4],y[4],vx[4],vy[4],length,deltay,deltax;
  25.  
  26. long    endTime;
  27.  
  28.  
  29.     GetPort(&oldPort);
  30.     SetRect(&creditRect, 75,75,425,235);
  31.     
  32.     creditWPtr = NewWindow((WindowPeek) 0L, &creditRect, "\1x", FALSE, dBoxProc, (WindowPtr) -1L, FALSE, 0L);
  33.     SetPort(creditWPtr);
  34.     
  35.     CenterWindow(creditWPtr);
  36.     ShowWindow(creditWPtr);
  37.  
  38. MAINLOOP:
  39.  
  40.     SetRect(&lineRect, 100,10,350,25);
  41.     
  42.     creditRect = creditWPtr->portRect;
  43.     
  44.     BackPat(black);
  45.     EraseRect(&creditRect);
  46.     
  47.     TextMode(srcXor);
  48.     TextSize(12);
  49.     TextFont(3);
  50.     TextFace(bold);
  51.     TextBox(line1, strlen(line1), &lineRect, teJustCenter);
  52.     OffsetRect(&lineRect, 0 , 20);
  53.     
  54.     TextSize(10);
  55.     TextBox(line2, strlen(line2), &lineRect, teJustCenter);
  56.     
  57.     TextFace(italic);
  58.     OffsetRect(&lineRect, 0 , 20);
  59.     TextBox(line3, strlen(line3), &lineRect, teJustCenter);
  60.     OffsetRect(&lineRect, 0 , 15);
  61.     TextBox(line4, strlen(line4), &lineRect, teJustCenter);
  62.     
  63.     TextFace(0);
  64.     OffsetRect(&lineRect, 0 , 25);
  65.     TextBox(line5, strlen(line5), &lineRect, teJustCenter);
  66.     OffsetRect(&lineRect, 0 , 15);
  67.     TextBox(line6, strlen(line6), &lineRect, teJustCenter);
  68.     OffsetRect(&lineRect, 0 , 15);
  69.     TextBox(line7, strlen(line7), &lineRect, teJustCenter);
  70.     OffsetRect(&lineRect, 0 , 15);
  71.     TextBox(line8, strlen(line8), &lineRect, teJustCenter);
  72.     
  73.     PenNormal();
  74.     PenMode(patXor);
  75.     
  76.     x[0] = x[2] = 50;
  77.     x[1] = x[3] = 10;
  78.     y[0] = y[2] = 45;
  79.     y[1] = y[3] = 55;
  80.     
  81.     vx[0] = vx[2] = 2;
  82.     vx[1] = vx[3] = -4;
  83.     vy[0] = vy[2] = 3;
  84.     vy[1] = vy[3] = -1;
  85.     
  86.     count = 20;
  87.     
  88.     creditRect = creditWPtr->portRect;
  89.     creditRect.right = 100;
  90.     
  91.     MoveTo((int) x[0],(int) y[0]);
  92.     LineTo((int) x[1],(int) y[1]);
  93.     
  94.     iticks = TickCount();
  95.     
  96.     BeginUpdate(creditWPtr);
  97.     EndUpdate(creditWPtr);
  98.     
  99.     do
  100.     {
  101.         if (count)
  102.             for (i=0;i<=1;i++)
  103.             {
  104.                 x[i] += vx[i];
  105.                 if (x[i] < creditRect.left + 5)
  106.                     vx[i] = (vx[i] > 0) ? vx[i] : -vx[i];
  107.                 else if (x[i] > creditRect.right - 5)
  108.                     vx[i] = (vx[i] < 0) ? vx[i] : -vx[i];
  109.                 
  110.                 y[i] += vy[i];
  111.                 if (y[i] < creditRect.top + 30)
  112.                     vy[i] = (vy[i] > 0) ? vy[i] : -vy[i];
  113.                 else if (y[i] > creditRect.bottom - 30)
  114.                     vy[i] = (vy[i] < 0) ? vy[i] : -vy[i];
  115.                     
  116.                 count--;
  117.             }
  118.         
  119.         else
  120.             for (i=0;i<=3;i++)
  121.             {
  122.                 x[i] += vx[i];
  123.                 if (x[i] < creditRect.left + 5)
  124.                     vx[i] = (vx[i] > 0) ? vx[i] : -vx[i];
  125.                 else if (x[i] > creditRect.right - 5)
  126.                     vx[i] = (vx[i] < 0) ? vx[i] : -vx[i];
  127.                 
  128.                 y[i] += vy[i];
  129.                 if (y[i] < creditRect.top + 30)
  130.                     vy[i] = (vy[i] > 0) ? vy[i] : -vy[i];
  131.                 else if (y[i] > creditRect.bottom - 30)
  132.                     vy[i] = (vy[i] < 0) ? vy[i] : -vy[i];
  133.                 
  134.             }
  135.         
  136.         MoveTo((int) x[0],(int) y[0]);
  137.         LineTo((int) x[1],(int) y[1]);    
  138.         
  139.         if (!count)
  140.         {
  141.             MoveTo((int) x[2],(int) y[2]);
  142.             LineTo((int) x[3],(int) y[3]);
  143.         }
  144.     
  145.         GetNextEvent(everyEvent, &theEvent);
  146.         
  147.         Delay(DURATION,&endTime);
  148.         
  149.         if (theEvent.what == updateEvt)
  150.             goto MAINLOOP;
  151.         
  152.     }    while ((!doWait && (theEvent.what != mouseDown))||(doWait && (TickCount() < iticks + doWait)));
  153.     
  154.     
  155.     DisposeWindow(creditWPtr);
  156.     
  157.     SetPort(oldPort);
  158. }
  159.  
  160.